//
//  LSDaiBanDetailVC.m
//  LaSaCivilAffairsDepartment
//
//  Created by 姜晓延 on 2019/8/22.
//  Copyright © 2019 wpkj. All rights reserved.
//

#import "LSDaiBanDetailVC.h"
#import "LSDownloadFilesViewController.h"
#import "LSContactSelectViewController.h"
#import "LSContactSelectTableViewModel.h"
#import "LSTestViewController.h"
#import "LSTestSelectModel.h"
#define tableViewCellHeight 100
@interface LSDaiBanDetailVC ()<UITextViewDelegate>
@property (nonatomic, strong) UIScrollView *scrollView;

@property (nonatomic, strong) UIButton *saveBtn;

@property (nonatomic, strong) UIView *fujianView;

@property (nonatomic, strong) NSMutableArray *upLoadFileArray;//已经上传的文件

@property (nonatomic, strong) NSMutableDictionary *progressDict;

@property (nonatomic, strong) NSMutableDictionary *detailDict;

@property (nonatomic, strong) NSMutableArray *filesArray;

@property (nonatomic, strong) UIView *progressHistoryView;

@property (nonatomic, strong) UIView *bottomVIew;

@property (nonatomic, assign) BOOL detailY;

@property (nonatomic, assign) BOOL progressY;

@property (nonatomic, strong) UIView *backgroundAlphaView;

@property (nonatomic, strong) NSMutableDictionary *paraDict;
//节点试图
@property (nonatomic, strong) UIView *jieDianView;
//驳回试图
@property (nonatomic, strong) UIView *bohuiView;

@property (nonatomic, strong) UIButton *bohuiBtn;
@property (nonatomic, strong) NSMutableArray *copToParentArray;
@property (nonatomic, copy) NSString *selectCopyToDepartmentString;
@end

@implementation LSDaiBanDetailVC
- (NSMutableArray*)copToParentArray{
    if (!_copToParentArray) {
        _copToParentArray = [NSMutableArray array];
    }
    return _copToParentArray;
}
- (NSMutableDictionary *)paraDict{
    if (!_paraDict) {
        _paraDict = [NSMutableDictionary dictionary];
    }
    return _paraDict;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.progressY = NO;
    self.detailY = NO;
    self.paraDict[@"rejectModelNode"] =@"";
    self.paraDict[@"taskName"] = @"";
    self.paraDict[@"option"] = @"确认提交";
    self.paraDict[@"ck_formsubmitflag"] = @"1";
    self.paraDict[@"taskId"] = self.dict[@"taskId"];
    self.title = @"办理";
    
    [self getNiWenData];
    [self getProgrssData];
    [self copyToDepartment];
    // Do any additional setup after loading the view.
}
#pragma mark 阅办*******************************************************************************
#pragma mark 拿到详情创建界面
- (void)makeYueBanViewWithDict:(NSDictionary*)dict{
    UIScrollView *scrollVIew = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight)];
    [self.view addSubview:scrollVIew];
    self.scrollView = scrollVIew;
    BOOL isedit = YES;
    if (![self.dict[@"taskName"] isEqualToString:@"发起审批"]) {
        isedit = NO;
    }
    NSArray *values = @[[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_NUM"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_RECEIVE_DATE"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_TITLE"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_COMPANY"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_CODE"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_CLASSIFY"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_COUNT"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"SECURITY_CLASSIFICATION"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_REMARK"]]]];
    NSArray *names = @[@"原文编号：",@"收文时间：",@"文件标题：",@"来文单位：",@"字号：",@"收文分类：",@"收文份数： ",@"密级：",@"备注："];

    CGFloat maxY = 0;
    for (NSInteger i = 0; i < names.count; i++) {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50)];
        view.backgroundColor = hexColor(ffffff);
        view.tag = 100000+i;
        [scrollVIew addSubview:view];
        
        UIImageView *hongdianImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 20, 10, 10)];
        hongdianImage.image = [UIImage imageNamed:@"xinhao"];
        hongdianImage.tag = 200000+i;
        //        hongdianImage.backgroundColor = [UIColor redColor];
        //        hongdianImage.clipsToBounds = YES;
        //        hongdianImage.layer.cornerRadius = 5;
        [view addSubview:hongdianImage];
        
        CGFloat maxX = CGRectGetMaxX(hongdianImage.frame);;
        if (i == 0 || i== 2 || i==3 || i == 4 || i==5 || i==6) {
            hongdianImage.hidden = NO;
        }else{
            
            hongdianImage.hidden = YES;
        }
        
        
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+maxX, 10, 80, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [view addSubview:titlelabel];
        titlelabel.tag = 300000+i;
        titlelabel.text = names[i];
        if (i == 8) {
            UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(10, 10+CGRectGetMaxY(titlelabel.frame), ScreenWidth-10-10, 200)];
            textView.delegate = self;
            textView.text = values[i];
            textView.tag = 100+i;
            textView.font = [UIFont systemFontOfSize:15];
            view.frame = CGRectMake(0, maxY, ScreenWidth, 10+30+10+200+10);
            [view addSubview:textView];
            textView.clipsToBounds = YES;
            textView.layer.borderColor = hexColor(666666).CGColor;
            textView.layer.borderWidth = 1;
            if (isedit) {
                textView.editable = YES;
            }else{
                textView.editable = NO;
            }
        }else{
            
            UITextView *textFiled = [[UITextView alloc]initWithFrame:CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-maxX, 30)];
            textFiled.textColor = hexColor(333333);
            textFiled.font = [UIFont systemFontOfSize:15];
            [view addSubview:textFiled];
            textFiled.delegate = self;
            textFiled.tag = 100+i;
            textFiled.scrollEnabled  =NO;
            textFiled.text = values[i];
            if (i == 5) {
                if ([values[i] isEqualToString:@"central"]) {
                    textFiled.text = @"中央文件";
                }else if ([values[i] isEqualToString:@"autonomousRegion"]){
                    textFiled.text = @"自治区文件";
                }else if ([values[i] isEqualToString:@"MuniGovernment"]){
                    textFiled.text = @"市委市政府文件";
                }else if ([values[i] isEqualToString:@"bureau"]){
                    textFiled.text = @"本局文件";
                }else if ([values[i] isEqualToString:@"MuniDepartments"]){
                    textFiled.text = @"市直相关部门文件";
                }
            }
            if (i == 7) {
                if ([values[i] isEqualToString:@"0"]) {
                    textFiled.text = @"公开";
                }else if ([values[i] isEqualToString:@"1"]){
                    textFiled.text = @"国内";
                }else if ([values[i] isEqualToString:@"2"]){
                    textFiled.text = @"内部";
                }else if ([values[i] isEqualToString:@"3"]){
                    textFiled.text = @"秘密";
                }else if ([values[i] isEqualToString:@"4"]){
                    textFiled.text = @"机密";
                }else if ([values[i] isEqualToString:@"5"]){
                    textFiled.text = @"绝密";
                }
            }
            if (isedit) {
                textFiled.editable = YES;
                if (i == 7) {
                    textFiled.textAlignment = NSTextAlignmentCenter;
                    textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                    textFiled.backgroundColor = hexColor(f0f0f0);
                    textFiled.editable = NO;
                    
                    UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                    zhankaiBtn.frame = CGRectMake(ScreenWidth-50, 5, 40, 40);
                    [zhankaiBtn setImage:[UIImage imageNamed:@"xiala"] forState:UIControlStateNormal];
                    zhankaiBtn.enabled = NO;
                    [view addSubview:zhankaiBtn];
                }
                if (i == 5) {
                    textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                    textFiled.backgroundColor = hexColor(f0f0f0);
                    textFiled.editable = NO;
                    textFiled.textAlignment = NSTextAlignmentCenter;
                    
                    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50+10, 15, 20, 20)];
                    imageView.image = [UIImage imageNamed:@"xiala"];
                    [view addSubview:imageView];
                    
                    UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                    zhankaiBtn.frame = CGRectMake(10+80, 5, ScreenWidth-90, 40);
                    [zhankaiBtn addTarget:self action:@selector(xuanzewenjinaleixing) forControlEvents:UIControlEventTouchUpInside];
                    [view addSubview:zhankaiBtn];
                   
                    
                }
            }else{
                textFiled.editable = NO;
                CGSize constraintSize = CGSizeMake(textFiled.frame.size.width, MAXFLOAT);
                       CGSize size = [textFiled sizeThatFits:constraintSize];
                       if (size.height>30) {
                           CGRect frame = textFiled.frame;
                           CGRect viewFrame = view.frame;
                           viewFrame.size.height = viewFrame.size.height+(size.height-frame.size.height);
                           view.frame = viewFrame;
                           
                           frame.size.height = size.height;
                           textFiled.frame = frame;
                           
                           CGRect titleFrame = titlelabel.frame;
                           titleFrame.origin.y = (view.frame.size.height-30)/2.0;
                           titlelabel.frame = titleFrame;
                           
                           CGRect redFrame = hongdianImage.frame;
                           redFrame.origin.y = (view.frame.size.height-10)/2.0;
                           hongdianImage.frame = redFrame;
                       }
            }
            if (i == 0 || i == 1) {
                textFiled.userInteractionEnabled = NO;
                if (i == 1) {
                    if ([ValidateUtils validateNull:values[i]].length > 10) {
                        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                        [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                        NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[values[i] substringToIndex:10] integerValue]];
                        
                        textFiled.text = [dateFormatter stringFromDate:date];
                        self.detailDict[@"FILE_RECEIVE_DATE"] = textFiled.text;
                    }
                }
            }
            if(i == 6){
                textFiled.keyboardType =  UIKeyboardTypeNumberPad;
            }
            if (i > 7) {
                textFiled.editable = NO;
            }
            UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, view.frame.size.height-1, ScreenWidth, 1)];
            lineViwe.backgroundColor = hexColor(f0f0f0);
            lineViwe.tag = 400000+i;
            [view addSubview:lineViwe];
        }
        
        maxY = CGRectGetMaxY(view.frame);
    }
    
    //,@"附件:"
    
    NSArray *arr  = [NSArray arrayWithArray:dict[@"ATTACHMENT"]];
    [self.upLoadFileArray addObjectsFromArray:arr];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50*(arr.count+1))];
    view.backgroundColor = hexColor(ffffff);
    [scrollVIew addSubview:view];
    self.fujianView = view;
    UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
    titlelabel.font = [UIFont systemFontOfSize:15];
    titlelabel.textColor = hexColor(333333);
    [view addSubview:titlelabel];
    titlelabel.text =@"附件：";
    UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    downBtn.frame = CGRectMake(ScreenWidth-50,5 , 40, 40);
    [downBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
    [downBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
    [view addSubview:downBtn];
    downBtn.tag = 2000;
    if (isedit) {
        downBtn.enabled = YES;
    }else{
        downBtn.enabled = NO;
    }
    [downBtn addTarget:self action:@selector(addFiles) forControlEvents:UIControlEventTouchUpInside];
    
    if (arr.count > 0) {
        for (NSInteger i = 0; i < arr.count; i++) {
            NSDictionary *dict = arr[i];
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(titlelabel.frame)+10 + i*50, ScreenWidth-10-10-40-50, 30)];
            label.font = [UIFont systemFontOfSize:14];
            label.textColor = hexColor(333333);
            label.text = dict[@"fileName"];
            [view addSubview:label];
            UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            downBtn.frame = CGRectMake(ScreenWidth-50-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
            [downBtn setImage:[UIImage imageNamed:@"xiazai"] forState:UIControlStateNormal];
            [view addSubview:downBtn];
            downBtn.tag = 5000+i;
            [downBtn addTarget:self action:@selector(downFileStart:) forControlEvents:UIControlEventTouchUpInside];
            
            UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            deleteBtn.frame = CGRectMake(ScreenWidth-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
            [deleteBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
            [self.fujianView addSubview:deleteBtn];
            deleteBtn.tag = 4000+i;
            [deleteBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
            
            UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
            lineViwe.backgroundColor = hexColor(f0f0f0);
            [view addSubview:lineViwe];
        }
    }
    
    maxY = CGRectGetMaxY(view.frame);
    scrollVIew.contentSize = CGSizeMake(0, maxY+10);
    
    NSArray *histListNode = [NSArray arrayWithArray:self.progressDict[@"bpmLogList"]];
    
    self.progressHistoryView = [[UIView alloc]initWithFrame:CGRectMake(0, maxY+10, ScreenWidth, 0)];
    self.progressHistoryView.backgroundColor = [UIColor whiteColor];
    [scrollVIew addSubview:self.progressHistoryView];
    CGFloat progressY = 0;
    for (NSInteger i = 0; i < histListNode.count; i++) {
        NSDictionary *dict = histListNode[i];
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, progressY, ScreenWidth, 10+30+30+30+30+10)];
        [self.progressHistoryView addSubview:view];
        
        UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
        imageview.image = [UIImage imageNamed:@"wancheng"];
        [view addSubview:imageview];
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10, ScreenWidth-40-10, 20)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [view addSubview:titlelabel];
        titlelabel.text = [ValidateUtils validateNull:dict[@"task_node"]];
        
        UILabel *titlelabel1 = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10+30, ScreenWidth-40-10, 20)];
        titlelabel1.font = [UIFont systemFontOfSize:15];
        titlelabel1.textColor = [UIColor redColor];
        [view addSubview:titlelabel1];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[ [ValidateUtils validateNull:dict[@"op_time"]] substringToIndex:10] integerValue]];
        
        titlelabel1.text = [NSString stringWithFormat:@"[处理时间：%@]",[dateFormatter stringFromDate:date]];
        
        UILabel *titlelabel2 = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10+30+30, ScreenWidth-40-10, 20)];
        titlelabel2.font = [UIFont systemFontOfSize:13];
        titlelabel2.textColor = hexColor(666666);
        [view addSubview:titlelabel2];
        titlelabel2.text = [NSString stringWithFormat:@"[操作人：%@]",[ValidateUtils validateNull:dict[@"op_name"]]];
        
        UILabel *titlelabel3 = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10+30+30+30, ScreenWidth-40-10, 20)];
        titlelabel3.font = [UIFont systemFontOfSize:15];
        titlelabel3.textColor = hexColor(4EC2F7);
        [view addSubview:titlelabel3];
        titlelabel3.text = [NSString stringWithFormat:@"处理意见：%@",[ValidateUtils validateNull:dict[@"memo"]]];
        titlelabel3.numberOfLines = 0;
        CGSize size = [titlelabel3 sizeThatFits:CGSizeMake(ScreenWidth-40-10, MAXFLOAT)];
        if (size.height>20) {
            titlelabel3.frame = CGRectMake(10+20+10, 10+30+30+30, ScreenWidth-40-10, size.height);
            view.frame = CGRectMake(0, progressY, ScreenWidth,10+30+30+30+size.height+10 );
        }
        progressY = CGRectGetMaxY(view.frame);
    }
    if (histListNode.count != 0) {
        self.progressHistoryView.frame =CGRectMake(0, maxY+10, ScreenWidth, progressY+10);
        maxY = CGRectGetMaxY(self.progressHistoryView.frame);
    }else{
        self.progressHistoryView.frame =CGRectMake(0, maxY+10, ScreenWidth, 0);
        maxY = CGRectGetMaxY(self.progressHistoryView.frame)-10;
    }
    
    
    CGFloat bottomHeight = 0;
    if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"]) {
        bottomHeight = 80 + 50+50;
    }else{
        bottomHeight = 80;
    }
    if ([ValidateUtils validateNull:self.progressDict[@"histListSize"]].integerValue > 0) {
        bottomHeight = bottomHeight+50;
    }
#pragma mark 办理阅办时图
    self.bottomVIew  = [[UIView alloc]initWithFrame:CGRectMake(0, maxY + 10, ScreenWidth, bottomHeight)];
    self.bottomVIew.backgroundColor = [UIColor whiteColor];
    [scrollVIew addSubview:self.bottomVIew];
    
    maxY = CGRectGetMaxY(self.bottomVIew.frame);
    UIView *lineview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 1)];
    lineview.backgroundColor = hexColor(eeeeee);
    [_bottomVIew addSubview:lineview];
    //办理意见
    UIView *yijianView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 80)];
    yijianView.backgroundColor = hexColor(ffffff);
    yijianView.tag = 10000;
    [_bottomVIew addSubview:yijianView];
    
    UIImageView *hongdianImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, 10, 10)];
    hongdianImage.image = [UIImage imageNamed:@"xinhao"];
    [yijianView addSubview:hongdianImage];
    
    UILabel *yijianLabel = [[UILabel alloc]initWithFrame:CGRectMake(10+CGRectGetMaxX(hongdianImage.frame), 10, 80, 20)];
    yijianLabel.font = [UIFont systemFontOfSize:15];
    yijianLabel.textColor = hexColor(333333);
    [yijianView addSubview:yijianLabel];
    yijianLabel.text = @"办理意见：";
    UITextView *YiJinatextFiled = [[UITextView alloc]initWithFrame:CGRectMake(10, 10+20+10, ScreenWidth-10-10, 30)];
    YiJinatextFiled.textColor = hexColor(333333);
    YiJinatextFiled.font = [UIFont systemFontOfSize:15];
    [yijianView addSubview:YiJinatextFiled];
    YiJinatextFiled.tag = 9000;
    YiJinatextFiled.delegate = self;
    YiJinatextFiled.clipsToBounds = YES;
//    YiJinatextFiled.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 30)];
//    YiJinatextFiled.leftViewMode = UITextFieldViewModeAlways;
    YiJinatextFiled.layer.borderColor = hexColor(eeeeee).CGColor;
    YiJinatextFiled.layer.borderWidth = 1;
    UIView *linevew1 = [[UIView alloc]initWithFrame:CGRectMake(0, 79, ScreenWidth, 1)];
    linevew1.backgroundColor = hexColor(eeeeee);
    linevew1.tag = 9001;
    [yijianView addSubview:linevew1];
    
    CGFloat yijianY = CGRectGetMaxY(yijianView.frame);
    
    //选择下一个界面
    if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"] ) {
        self.jieDianView = [[UIView alloc]initWithFrame:CGRectMake(0, yijianY+1, ScreenWidth, 100)];
        self.jieDianView.backgroundColor = [UIColor whiteColor];
        [self.bottomVIew addSubview:self.jieDianView];
        yijianY = CGRectGetMaxY(self.jieDianView.frame);
        NSArray *arr = @[@"请选择下一个节点:",@"下一个节点处理人："];
        for (NSInteger i = 0; i < arr.count; i++) {
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, i*50, ScreenWidth, 50)];
            view.backgroundColor = hexColor(ffffff);
            [self.jieDianView addSubview:view];
            
            UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 140, 30)];
            titlelabel.font = [UIFont systemFontOfSize:15];
            titlelabel.textColor = hexColor(333333);
            [view addSubview:titlelabel];
            titlelabel.text = arr[i];
            
            UITextField *textFiled = [[UITextField alloc]initWithFrame:CGRectMake(10+120,10, ScreenWidth-10-140-40, 30)];
            textFiled.textColor = hexColor(333333);
            textFiled.font = [UIFont systemFontOfSize:15];
            [view addSubview:textFiled];
//            textFiled.delegate = self;
            textFiled.tag = 8000+i;
            textFiled.textAlignment = NSTextAlignmentCenter;
            textFiled.enabled = NO;
            if (i == 0) {
                NSArray *arr = [NSArray arrayWithArray:self.progressDict[@"tasknodes"]];
                if (arr.count>0) {
                    textFiled.text = arr[0][@"PROCESSNODENAME"];
                    self.paraDict[@"SELECT_TASKNODE"] = [NSString stringWithFormat:@"1_%@",arr[0][@"PROCESSNODECODE"]];
                }
            }
            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50+10,15, 20, 20)];
           
            [view addSubview:imageView];
            imageView.userInteractionEnabled = YES;
            UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            zhankaiBtn.frame = CGRectMake(10+80, 5, ScreenWidth-90, 40);
            if (i == 0) {
                 imageView.image = [UIImage imageNamed:@"xiala"];
                [zhankaiBtn addTarget:self action:@selector(isopenchoose) forControlEvents:UIControlEventTouchUpInside];
            }else{
                 imageView.image = [UIImage imageNamed:@"lct"];
                textFiled.placeholder = @"选择处理人";
                [zhankaiBtn addTarget:self action:@selector(chooseJieDianChuLuRen) forControlEvents:UIControlEventTouchUpInside];
            }
            [view addSubview:zhankaiBtn];
            UIView *linevew1 = [[UIView alloc]initWithFrame:CGRectMake(0, 49, ScreenWidth, 1)];
            linevew1.backgroundColor = hexColor(eeeeee);
            [view addSubview:linevew1];
        }
        
    }
    //驳回
    
    if ([ValidateUtils validateNull:self.progressDict[@"histListSize"]].integerValue > 0) {
        self.bohuiView = [[UIView alloc]initWithFrame:CGRectMake(0, yijianY, ScreenWidth, 50)];
        
        [self.bottomVIew addSubview:self.bohuiView];
        UIButton *bohuiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        bohuiBtn.frame = CGRectMake(10, 10, 80, 30);
        [bohuiBtn setImage:[UIImage imageNamed:@"icon-test"] forState:UIControlStateNormal];
        [bohuiBtn setImage:[UIImage imageNamed:@"fangxuankuang2"] forState:UIControlStateSelected];
        [bohuiBtn setTitleColor:hexColor(333333) forState:UIControlStateNormal];
        [bohuiBtn setTitleColor:hexColor(333333) forState:UIControlStateSelected];
        self.bohuiBtn = bohuiBtn;
        [bohuiBtn setTitle:@"驳回" forState:UIControlStateSelected];
        [bohuiBtn setTitle:@"驳回" forState:UIControlStateNormal];
        [bohuiBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0,5)];
        [self.bohuiView addSubview:bohuiBtn];
        bohuiBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [bohuiBtn addTarget:self action:@selector(bohuiBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+80+10, 10, 120, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(666666);
        [self.bohuiView addSubview:titlelabel];
        titlelabel.text = @"发起审批" ;
    }
    
    
    self.saveBtn  = [UIButton buttonWithType:UIButtonTypeCustom];
    self.saveBtn.backgroundColor = hexColor(FFBC01);
    [self.saveBtn setTitle:@"提交" forState:UIControlStateNormal];
    self.saveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.saveBtn.frame = CGRectMake(20, maxY+20, ScreenWidth-40, 40);
    [scrollVIew addSubview:self.saveBtn];
    
    self.saveBtn.clipsToBounds = YES;
    self.saveBtn.layer.cornerRadius = 5;
    
    scrollVIew.contentSize = CGSizeMake(0, CGRectGetMaxY(self.saveBtn.frame)+10);
    [self.saveBtn addTarget:self action:@selector(subData:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)xuanzewenjinaleixing{
    NSArray *names = @[@"中央文件",@"自治区文件",@"市委市政府文件",@"本局文件",@"市直相关部门文件"];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(20, 250+SafeAreaTopHeight, ScreenWidth-40, names.count*51)];
    view.backgroundColor = hexColor(ffffff);
    [self.backgroundAlphaView addSubview:view];
    
    for (NSInteger i = 0; i < names.count; i++) {
        UIButton *yesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        yesBtn.frame = CGRectMake(0, i*51, ScreenWidth-40, 50);
        [yesBtn setTitle:names[i] forState:UIControlStateNormal];
        [yesBtn setTitleColor:hexColor(333333) forState:UIControlStateNormal];
        [view addSubview:yesBtn];
        yesBtn.tag = 1000+i;
        [yesBtn addTarget:self action:@selector(fileTypeselcect:) forControlEvents:UIControlEventTouchUpInside];
        UIView *lineview = [[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth-40, 1)];
        lineview.backgroundColor = hexColor(f0f0f0);
        [view addSubview:lineview];
    }
}
#pragma mark 拟文*******************************************************************************
#pragma mark 选择下一个节点
- (void)isopenchoose{
    //    [self.backgroundAlphaView removeFromSuperview];
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self.backgroundAlphaView];
  
        NSArray *names = [NSArray arrayWithArray:self.progressDict[@"tasknodes"]];
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(20, 250+SafeAreaTopHeight, ScreenWidth-40, names.count*51)];
        view.backgroundColor = hexColor(ffffff);
        [self.backgroundAlphaView addSubview:view];
        
        for (NSInteger i = 0; i < names.count; i++) {
            UIButton *yesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            yesBtn.frame = CGRectMake(0, i*51, ScreenWidth-40, 50);
            [yesBtn setTitle:names[i][@"PROCESSNODENAME"] forState:UIControlStateNormal];
            [yesBtn setTitleColor:hexColor(333333) forState:UIControlStateNormal];
            [view addSubview:yesBtn];
            yesBtn.tag = 1000+i;
            [yesBtn addTarget:self action:@selector(yes:) forControlEvents:UIControlEventTouchUpInside];
            UIView *lineview = [[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth-40, 1)];
            lineview.backgroundColor = hexColor(f0f0f0);
            [view addSubview:lineview];
        }
  
    
}
- (void)fileTypeselcect:(UIButton*)button{
    UITextField *textFiled = [self.view viewWithTag:105];
    
    if (button.tag == 1000) {
        textFiled.text = @"中央文件";
        self.detailDict[@"FILE_CLASSIFY"] = @"central";
    }else if (button.tag == 1001){
        textFiled.text = @"自治区文件";
        self.detailDict[@"FILE_CLASSIFY"] = @"autonomousRegion";
    }else if (button.tag == 1002){
        textFiled.text = @"市委市政府文件";
        self.detailDict[@"FILE_CLASSIFY"] = @"MuniGovernment";
    }else if (button.tag == 1003){
        textFiled.text = @"本局文件";
        self.detailDict[@"FILE_CLASSIFY"] = @"bureau";
    }else if (button.tag == 1004){
        textFiled.text = @"市直相关部门文件";
        self.detailDict[@"FILE_CLASSIFY"] = @"MuniDepartments";
    }
    [self.backgroundAlphaView removeFromSuperview];
}
- (void)yes:(UIButton*)button{
    UITextField *textFiled = [self.view viewWithTag:8000];
      NSArray *names = [NSArray arrayWithArray:self.progressDict[@"tasknodes"]];
    textFiled.text = names[button.tag -1000][@"PROCESSNODENAME"];
    self.paraDict[@"SELECT_TASKNODE"] = [NSString stringWithFormat:@"%ld_%@",button.tag -1000+1,names[button.tag -1000][@"PROCESSNODECODE"]];
    [self.backgroundAlphaView removeFromSuperview];
}
- (void)textViewDidEndEditing:(UITextView *)textView{
    if (textView.tag == 108) {
        self.paraDict[@"FILE_REMARK"] = textView.text;
    }
     if (textView.tag == 9000) {
          self.paraDict[@"reason"] = textView.text;
          return;
      }
    if (self.type == 1) {
         
           switch (textView.tag) {
               case 100:
               {
                   self.detailDict[@"FILE_TITLE"] = textView.text;
               }
                   break;
               case 101:
               {
                   self.detailDict[@"FILE_REASON"] = textView.text;
               }
                   break;
               case 102:
               {
                   self.detailDict[@"FILE_CODE"] = textView.text;
               }
                   break;
                   //        case 105:
                   //        {
                   //             self.paraDict[@"notOpenReason"] = textField.text;
                   //        }
                   //            break;
               case 105:
               {
                   self.detailDict[@"HOST_ORGAN"] = textView.text;
               }
                   break;
               case 106:
               {
                   self.detailDict[@"COPY_TO"] = textView.text;
               }
                   break;
               case 107:
               {
                   self.detailDict[@"PRINT_COUNT"] = textView.text;
               }
                   break;
                   
               default:
                   break;
           }
       }else{
           switch (textView.tag) {
               case 102:
               {
                   self.detailDict[@"FILE_TITLE"] = textView.text;
               }
                   break;
               case 103:
               {
                   self.detailDict[@"FILE_COMPANY"] = textView.text;
               }
                   break;
               case 104:
               {
                   self.detailDict[@"FILE_CODE"] = textView.text;
               }
                   break;
                  
               case 106:
               {
                   self.detailDict[@"FILE_COUNT"] = textView.text;
               }
                   break;
                   
               default:
                   break;
           }
       }
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if (textView.tag == 108) {
        if (range.location >499 || [NSString stringWithFormat:@"%@%@",textView.text,text].length > 500) {
            textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:500];
            return NO;
        }
    }
     if (self.type == 1) {
           if (textView.tag == 107) {
               if (range.location > 2) {
                   return NO;
               }
           }
           switch (textView.tag) {
               case 100:
               {
                   if (range.location > 99 || [NSString stringWithFormat:@"%@%@",textView.text,text].length > 100) {
                        textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:100];
                                  return NO;
                   } else {
                       if (([ValidateUtils isInputRuleNotBlank:text] && ![ValidateUtils hasSpecialString:text]) || [text isEqualToString:@""]) {//当输入符合规则和退格键时允许改变输入框
                           return YES;
                       } else {
                           return NO;
                       }
                   }
               }
                   break;
               case 101:
               {
                   if (range.location > 99 || [NSString stringWithFormat:@"%@%@",textView.text,text].length > 100) {
                       textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:100];
                        return NO;
                   } else {
                       if (([ValidateUtils isInputRuleNotBlank:text] && ![ValidateUtils hasSpecialString:text]) || [text isEqualToString:@""]) {//当输入符合规则和退格键时允许改变输入框
                           return YES;
                       } else {
                           return NO;
                       }
                   }
               }
                   break;
               case 102:
               {
                   if (range.location > 24 || [NSString stringWithFormat:@"%@%@",textView.text,text].length > 25) {
                      textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:25];
                       return NO;
                   };
               }
                   break;
                  
               case 105:
               {
                   
                   if (range.location > 24 || [NSString stringWithFormat:@"%@%@",textView.text,text].length > 25) {
                                       textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:25];
                                        return NO;
                                    }
               }
                   break;
               case 106:
               {
                   
                  if (range.location > 24 || [NSString stringWithFormat:@"%@%@",textView.text,text].length > 25) {
                                       textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:25];
                                        return NO;
                                    };
               }
                   break;
               case 107:
               {
                   
                    if (range.location > 9 || [NSString stringWithFormat:@"%@%@",textView.text,text].length > 10) {
                                       textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:10];
                                        return NO;
                                    };
               }
                   break;
                   
               default:
                   break;
           }
           return YES;
       }else{
           if (textView.tag == 102) {
               if (range.location > 29|| [NSString stringWithFormat:@"%@%@",textView.text,text].length > 30) {
                 textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:30];
                       return NO;
                   } else {
                   if (([ValidateUtils isInputRuleNotBlank:text] && ![ValidateUtils hasSpecialString:text]) || [text isEqualToString:@""]) {//当输入符合规则和退格键时允许改变输入框
                       return YES;
                   } else {
                       return NO;
                   }
               }
           }
           if (textView.tag == 103) {
               if (range.location > 29|| [NSString stringWithFormat:@"%@%@",textView.text,text].length > 30) {
                     textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:30];
                                        return NO;
               } else {
                   if (([ValidateUtils isInputRuleNotBlank:text] && ![ValidateUtils hasSpecialString:text]) || [text isEqualToString:@""]) {//当输入符合规则和退格键时允许改变输入框
                       return YES;
                   } else {
                       return NO;
                   }
               }
           }
           if (textView.tag == 104) {
               if (range.location > 15|| [NSString stringWithFormat:@"%@%@",textView.text,text].length > 16) {
                   textView.text = [[NSString stringWithFormat:@"%@%@",textView.text,text] substringToIndex:16];
                                                          return NO;
               }
           }
           if (textView.tag == 106) {
               if (range.location > 2) {
                   return NO;
               }
           }
           return YES;
       }
}
- (UIView *)backgroundAlphaView {
    if (!_backgroundAlphaView) {
        _backgroundAlphaView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
        _backgroundAlphaView.backgroundColor = hexColorAlpha(000000, 0.5);
        _backgroundAlphaView.userInteractionEnabled = true;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundAlphaViewTapped)];
        [_backgroundAlphaView addGestureRecognizer:tap];
    }
    return _backgroundAlphaView;
}

- (void)backgroundAlphaViewTapped {
    [self.backgroundAlphaView removeFromSuperview];
    
}
- (NSMutableDictionary *)detailDict{
    if (!_detailDict) {
        _detailDict = [NSMutableDictionary dictionary];
    }
    return _detailDict;
}
- (NSMutableArray *)upLoadFileArray{
    if (!_upLoadFileArray) {
        _upLoadFileArray = [NSMutableArray array];
    }
    return _upLoadFileArray;
}
- (NSMutableDictionary *)progressDict{
    if (!_progressDict) {
        _progressDict = [NSMutableDictionary dictionary];
    }
    return _progressDict;
}

- (NSMutableArray *)filesArray {
    if (!_filesArray) {
        _filesArray = [NSMutableArray array];
    }
    return _filesArray;
}

#pragma mark 拟文办理
- (void)getProgrssData{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",gobl,[UserInfoModel sharedInstance].token] param:@{@"taskId":[ValidateUtils validateNull:self.dict[@"taskId"]]} completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        self.progressY = YES;
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
                [self.progressDict addEntriesFromDictionary:[responseObject[@"data"]firstObject]];
            } else {
                if ([responseObject[@"message"] isEqualToString:@"数据异常，请联系管理员"]) {
                    NSLog(@"就是这个接口--%@",gobl);
                }
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        } else {
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
        if (self.detailY && self.progressY) {
            if (self.type == 1) {
                 [self makeViewWithDict:self.detailDict];
            }else{
                [self makeYueBanViewWithDict:self.detailDict];
            }
           
        }
        
    }];
}

- (void)getNiWenData{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",blxx,[UserInfoModel sharedInstance].token] param:@{@"procInstId":[ValidateUtils validateNull:self.dict[@"procInstId"]],@"definitionName":[ValidateUtils validateNull:self.dict[@"definitionName"]]} completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        self.detailY = YES;
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            
            if (status.integerValue == 200) {
                [self.detailDict addEntriesFromDictionary:[responseObject[@"data"]firstObject]];
            } else {
                [self.detailDict addEntriesFromDictionary:self.dict];
                if ([responseObject[@"message"] isEqualToString:@"数据异常，请联系管理员"]) {
                    NSLog(@"就是这个接口--%@",blxx);
                }
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        } else {
            [self.detailDict addEntriesFromDictionary:self.dict];
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
        if (self.detailY && self.progressY) {
            if (self.type == 1) {
                [self makeViewWithDict:self.detailDict];
            }else{
                [self makeYueBanViewWithDict:self.detailDict];
            }
        }
        
    }];
}

- (void)makeViewWithDict:(NSDictionary*)dict{
    UIScrollView *scrollVIew = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight)];
    [self.view addSubview:scrollVIew];
    self.scrollView = scrollVIew;
    BOOL isedit = YES;
    if (![self.dict[@"taskName"] isEqualToString:@"发起审批"]) {
        isedit = NO;
    }
    NSArray *values = @[[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_TITLE"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_REASON"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"FILE_CODE"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"RANK"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"IS_OPEN"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"HOST_ORGAN"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"DEPART_NAMES"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"PRINT_COUNT"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"CREATE_NAME"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"CREATE_DATE"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"SYS_ORG_NAME"]]]];
    NSArray *names = @[@"拟文名称：",@"拟文事由：",@"拟文字号：",@"密级：",@"是否公开：",@"主送单位：",@"抄送单位： ",@"份数：",@"拟稿人：",@"拟稿日期：",@"拟稿部门："];
    CGFloat maxY = 0;
    for (NSInteger i = 0; i < names.count; i++) {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50)];
        view.backgroundColor = hexColor(ffffff);
        view.tag = 100000+i;
        [scrollVIew addSubview:view];
        
        UIImageView *hongdianImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 20, 10, 10)];
        hongdianImage.image = [UIImage imageNamed:@"xinhao"];
        hongdianImage.tag = 200000+i;
        [view addSubview:hongdianImage];
        
        CGFloat maxX = CGRectGetMaxX(hongdianImage.frame);;
        if (i == 0 || i== 1 || i==2 || i == 5 || i==7) {
            hongdianImage.hidden = NO;
        }else{
            
            hongdianImage.hidden = YES;
        }
        
        
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+maxX, 10, 80, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [view addSubview:titlelabel];
        titlelabel.tag = 300000+i;
        titlelabel.text = names[i];
        
        
        UITextView *textFiled = [[UITextView alloc]initWithFrame:CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-maxX, 30)];
        textFiled.textColor = hexColor(333333);
        textFiled.font = [UIFont systemFontOfSize:15];
        [view addSubview:textFiled];
        textFiled.delegate = self;
        textFiled.tag = 100+i;
        textFiled.scrollEnabled  =NO;
        textFiled.text = values[i];
        if (isedit) {
            if (i == 3) {
                textFiled.textAlignment = NSTextAlignmentCenter;
                textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                textFiled.backgroundColor = hexColor(f0f0f0);
                textFiled.editable = NO;
                
                UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                zhankaiBtn.frame = CGRectMake(ScreenWidth-50, 5, 40, 40);
                [zhankaiBtn setImage:[UIImage imageNamed:@"xiala"] forState:UIControlStateNormal];
                zhankaiBtn.enabled = NO;
                [view addSubview:zhankaiBtn];
            }
            if (i == 4) {
                textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                textFiled.backgroundColor = hexColor(f0f0f0);
                textFiled.editable = NO;
                textFiled.textAlignment = NSTextAlignmentCenter;
                
                UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50+10, 15, 20, 20)];
                imageView.image = [UIImage imageNamed:@"xiala"];
                [view addSubview:imageView];
                
                UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                zhankaiBtn.frame = CGRectMake(10+80, 5, ScreenWidth-90, 40);
                zhankaiBtn.enabled = NO;
                [view addSubview:zhankaiBtn];
            }
        }else{
            textFiled.editable = NO;
              CGSize constraintSize = CGSizeMake(textFiled.frame.size.width, MAXFLOAT);
            CGSize size = [textFiled sizeThatFits:constraintSize];
            if (size.height>30) {
                CGRect frame = textFiled.frame;
                CGRect viewFrame = view.frame;
                viewFrame.size.height = viewFrame.size.height+(size.height-frame.size.height);
                  view.frame = viewFrame;
                frame.size.height = size.height;
                textFiled.frame = frame;
                CGRect titleFrame = titlelabel.frame;
                titleFrame.origin.y = (view.frame.size.height-30)/2.0;
                titlelabel.frame = titleFrame;
                CGRect redFrame = hongdianImage.frame;
              redFrame.origin.y = (view.frame.size.height-10)/2.0;
              hongdianImage.frame = redFrame;
            }
        }
    
        if(i == 7){
            textFiled.keyboardType =  UIKeyboardTypeNumberPad;
        }
        if (i == 6) {
                  textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                  textFiled.editable = NO;
                  UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50+10, 15, 20, 20)];
                  imageView.image = [UIImage imageNamed:@"xiala"];
                  imageView.userInteractionEnabled = YES;
                  [view addSubview:imageView];
                  UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                  zhankaiBtn.frame = CGRectMake(10+80, 5, ScreenWidth-90, 40);
                  [zhankaiBtn addTarget:self action:@selector(selectCopyToDepartment) forControlEvents:UIControlEventTouchUpInside];
                  zhankaiBtn.tag = 8888;
                  [view addSubview:zhankaiBtn];
              }
        if (i == 3) {
            if ([values[i] isEqualToString:@"0"]) {
                textFiled.text = @"公开";
            }else if ([values[i] isEqualToString:@"1"]){
                textFiled.text = @"国内";
            }else if ([values[i] isEqualToString:@"2"]){
                textFiled.text = @"内部";
            }else if ([values[i] isEqualToString:@"3"]){
                textFiled.text = @"秘密";
            }else if ([values[i] isEqualToString:@"4"]){
                textFiled.text = @"机密";
            }else if ([values[i] isEqualToString:@"5"]){
                textFiled.text = @"绝密";
            }
        }
        if (i == 4) {
            textFiled.editable = NO;
            if ([values[i] isEqualToString:@"0"]) {
                textFiled.text = @"否";
            }else if ([values[i] isEqualToString:@"1"]){
                textFiled.text = @"是";
            }
        }
        if (i > 7) {
            textFiled.editable = NO;
        }
        if (i == 9) {
            if ([ValidateUtils validateNull:values[i]].length > 10) {
                NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[values[i] substringToIndex:10] integerValue]];
                
                textFiled.text = [dateFormatter stringFromDate:date];
            }
        }
        UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, view.frame.size.height-1, ScreenWidth, 1)];
        lineViwe.backgroundColor = hexColor(f0f0f0);
        [view addSubview:lineViwe];
        lineViwe.tag = 400000+i;
        maxY = CGRectGetMaxY(view.frame);
    }
    
    //,@"附件:"
    
    NSArray *arr  = [NSArray arrayWithArray:dict[@"ATTACHMENT"]];
    [self.upLoadFileArray addObjectsFromArray:arr];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50*(arr.count+1))];
    view.backgroundColor = hexColor(ffffff);
    [scrollVIew addSubview:view];
    self.fujianView = view;
    UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
    titlelabel.font = [UIFont systemFontOfSize:15];
    titlelabel.textColor = hexColor(333333);
    [view addSubview:titlelabel];
    titlelabel.text =@"附件：";
    UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    downBtn.frame = CGRectMake(ScreenWidth-50,5 , 40, 40);
    [downBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
    [downBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
    [view addSubview:downBtn];
    downBtn.tag = 2000;
    if (isedit) {
        downBtn.enabled = YES;
    }else{
        downBtn.enabled = NO;
    }
    [downBtn addTarget:self action:@selector(addFiles) forControlEvents:UIControlEventTouchUpInside];
    
    if (arr.count > 0) {
        for (NSInteger i = 0; i < arr.count; i++) {
            NSDictionary *dict = arr[i];
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(titlelabel.frame)+10 + i*50, ScreenWidth-10-10-40-50, 30)];
            label.font = [UIFont systemFontOfSize:14];
            label.textColor = hexColor(333333);
            label.text = dict[@"fileName"];
            [view addSubview:label];
            UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            downBtn.frame = CGRectMake(ScreenWidth-50-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
            [downBtn setImage:[UIImage imageNamed:@"xiazai"] forState:UIControlStateNormal];
            [view addSubview:downBtn];
            downBtn.tag = 5000+i;
            [downBtn addTarget:self action:@selector(downFileStart:) forControlEvents:UIControlEventTouchUpInside];
            
            UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            deleteBtn.frame = CGRectMake(ScreenWidth-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
            [deleteBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
            [self.fujianView addSubview:deleteBtn];
            deleteBtn.tag = 4000+i;
            [deleteBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
            
            UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
            lineViwe.backgroundColor = hexColor(f0f0f0);
            [view addSubview:lineViwe];
        }
    }
    
    maxY = CGRectGetMaxY(view.frame);
    scrollVIew.contentSize = CGSizeMake(0, maxY+10);
    
    NSArray *histListNode = [NSArray arrayWithArray:self.progressDict[@"bpmLogList"]];
    
    self.progressHistoryView = [[UIView alloc]initWithFrame:CGRectMake(0, maxY+10, ScreenWidth, 0)];
    self.progressHistoryView.backgroundColor = [UIColor whiteColor];
    [scrollVIew addSubview:self.progressHistoryView];
    CGFloat progressY = 0;
    for (NSInteger i = 0; i < histListNode.count; i++) {
        NSDictionary *dict = histListNode[i];
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, progressY, ScreenWidth, 10+30+30+30+30+10)];
        [self.progressHistoryView addSubview:view];
        
        UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
        imageview.image = [UIImage imageNamed:@"wancheng"];
        [view addSubview:imageview];
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10, ScreenWidth-40-10, 20)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [view addSubview:titlelabel];
        titlelabel.text = [ValidateUtils validateNull:dict[@"task_node"]];
        
        UILabel *titlelabel1 = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10+30, ScreenWidth-40-10, 20)];
        titlelabel1.font = [UIFont systemFontOfSize:15];
        titlelabel1.textColor = [UIColor redColor];
        [view addSubview:titlelabel1];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[ [ValidateUtils validateNull:dict[@"op_time"]] substringToIndex:10] integerValue]];
        
        titlelabel1.text = [NSString stringWithFormat:@"[处理时间：%@]",[dateFormatter stringFromDate:date]];
        
        UILabel *titlelabel2 = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10+30+30, ScreenWidth-40-10, 20)];
        titlelabel2.font = [UIFont systemFontOfSize:13];
        titlelabel2.textColor = hexColor(666666);
        [view addSubview:titlelabel2];
        titlelabel2.text = [NSString stringWithFormat:@"[操作人：%@]",[ValidateUtils validateNull:dict[@"op_name"]]];
        
        UILabel *titlelabel3 = [[UILabel alloc]initWithFrame:CGRectMake(10+20+10, 10+30+30+30, ScreenWidth-40-10, 20)];
        titlelabel3.font = [UIFont systemFontOfSize:15];
        titlelabel3.textColor = hexColor(4EC2F7);
        [view addSubview:titlelabel3];
        titlelabel3.text = [NSString stringWithFormat:@"处理意见：%@",[ValidateUtils validateNull:dict[@"memo"]]];
        titlelabel3.numberOfLines = 0;
        CGSize size = [titlelabel3 sizeThatFits:CGSizeMake(ScreenWidth-40-10, MAXFLOAT)];
        if (size.height>20) {
            titlelabel3.frame = CGRectMake(10+20+10, 10+30+30+30, ScreenWidth-40-10, size.height);
            view.frame = CGRectMake(0, progressY, ScreenWidth,10+30+30+30+size.height+10 );
        }
        progressY = CGRectGetMaxY(view.frame);
    }
    if (histListNode.count != 0) {
         self.progressHistoryView.frame =CGRectMake(0, maxY+10, ScreenWidth, progressY+10);
         maxY = CGRectGetMaxY(self.progressHistoryView.frame);
    }else{
         self.progressHistoryView.frame =CGRectMake(0, maxY+10, ScreenWidth, 0);
         maxY = CGRectGetMaxY(self.progressHistoryView.frame)-10;
    }
   
    
    CGFloat bottomHeight = 0;
    if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"]) {
        bottomHeight = 80 + 50+50;
    }else{
        bottomHeight = 80;
    }
    if ([ValidateUtils validateNull:self.progressDict[@"histListSize"]].integerValue > 0) {
        bottomHeight = bottomHeight+50;
    }
#pragma mark 办理时图
    self.bottomVIew  = [[UIView alloc]initWithFrame:CGRectMake(0, maxY + 10, ScreenWidth, bottomHeight)];
    self.bottomVIew.backgroundColor = [UIColor whiteColor];
    [scrollVIew addSubview:self.bottomVIew];
    
     maxY = CGRectGetMaxY(self.bottomVIew.frame);
    UIView *lineview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 1)];
    lineview.backgroundColor = hexColor(eeeeee);
    [_bottomVIew addSubview:lineview];
    //办理意见
    UIView *yijianView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 80)];
    yijianView.backgroundColor = hexColor(ffffff);
    yijianView.tag = 10000;
    [_bottomVIew addSubview:yijianView];
    
    UIImageView *hongdianImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, 10, 10)];
    hongdianImage.image = [UIImage imageNamed:@"xinhao"];
    [yijianView addSubview:hongdianImage];
    
    UILabel *yijianLabel = [[UILabel alloc]initWithFrame:CGRectMake(10+CGRectGetMaxX(hongdianImage.frame), 10, 80, 20)];
    yijianLabel.font = [UIFont systemFontOfSize:15];
    yijianLabel.textColor = hexColor(333333);
    [yijianView addSubview:yijianLabel];
    yijianLabel.text = @"办理意见：";
    UITextView *YiJinaTV = [[UITextView alloc]initWithFrame:CGRectMake(10, 10+20+10, ScreenWidth-10-10, 30)];
    YiJinaTV.textColor = hexColor(333333);
    YiJinaTV.font = [UIFont systemFontOfSize:15];
    [yijianView addSubview:YiJinaTV];
    YiJinaTV.tag = 9000;
    YiJinaTV.delegate = self;
    YiJinaTV.clipsToBounds = YES;
//    YiJinaTV.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 30)];
//    YiJinaTV.leftViewMode = UITextFieldViewModeAlways;
    YiJinaTV.layer.borderColor = hexColor(eeeeee).CGColor;
    YiJinaTV.layer.borderWidth = 1;
    UIView *linevew1 = [[UIView alloc]initWithFrame:CGRectMake(0, 79, ScreenWidth, 1)];
    linevew1.tag = 9001;
    linevew1.backgroundColor = hexColor(eeeeee);
    [yijianView addSubview:linevew1];
    
    CGFloat yijianY = CGRectGetMaxY(yijianView.frame);
   
    //选择下一个界面
    if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"] ) {
        self.jieDianView = [[UIView alloc]initWithFrame:CGRectMake(0, yijianY+1, ScreenWidth, 100)];
        self.jieDianView.backgroundColor = [UIColor whiteColor];
        [self.bottomVIew addSubview:self.jieDianView];
        yijianY = CGRectGetMaxY(self.jieDianView.frame);
        NSArray *arr = @[@"请选择下一个节点:",@"下一个节点处理人："];
        for (NSInteger i = 0; i < arr.count; i++) {
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, i*50, ScreenWidth, 50)];
            view.backgroundColor = hexColor(ffffff);
            [self.jieDianView addSubview:view];
            
            UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 140, 30)];
            titlelabel.font = [UIFont systemFontOfSize:15];
            titlelabel.textColor = hexColor(333333);
            [view addSubview:titlelabel];
            titlelabel.text = arr[i];
            
            UITextField *textFiled = [[UITextField alloc]initWithFrame:CGRectMake(10+120,10, ScreenWidth-10-140-40, 30)];
            textFiled.textColor = hexColor(333333);
            textFiled.font = [UIFont systemFontOfSize:15];
            [view addSubview:textFiled];
//            textFiled.delegate = self;
            textFiled.tag = 8000+i;
            textFiled.textAlignment = NSTextAlignmentCenter;
            textFiled.enabled = NO;
            if (i == 0) {
                NSArray *arr = [NSArray arrayWithArray:self.progressDict[@"tasknodes"]];
                if (arr.count>0) {
                    textFiled.text = arr[0][@"PROCESSNODENAME"];
                    self.paraDict[@"SELECT_TASKNODE"] = [NSString stringWithFormat:@"1_%@",arr[0][@"PROCESSNODECODE"]];
                }
            }
            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50+10,15, 20, 20)];
            
            [view addSubview:imageView];
            imageView.userInteractionEnabled = YES;
            UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
           zhankaiBtn.frame = CGRectMake(10+80, 5, ScreenWidth-90, 40);
            if (i == 0) {
                imageView.image = [UIImage imageNamed:@"xiala"];
                [zhankaiBtn addTarget:self action:@selector(isopenchoose) forControlEvents:UIControlEventTouchUpInside];
            }else{
                imageView.image = [UIImage imageNamed:@"lct"];
                textFiled.placeholder = @"选择处理人";
                [zhankaiBtn addTarget:self action:@selector(chooseJieDianChuLuRen) forControlEvents:UIControlEventTouchUpInside];
            }
            [view addSubview:zhankaiBtn];
            UIView *linevew1 = [[UIView alloc]initWithFrame:CGRectMake(0, 49, ScreenWidth, 1)];
            linevew1.backgroundColor = hexColor(eeeeee);
            [view addSubview:linevew1];
        }
   
    }
    //驳回
  
    if ([ValidateUtils validateNull:self.progressDict[@"histListSize"]].integerValue > 0) {
        self.bohuiView = [[UIView alloc]initWithFrame:CGRectMake(0, yijianY, ScreenWidth, 50)];
       
        [self.bottomVIew addSubview:self.bohuiView];
        UIButton *bohuiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        bohuiBtn.frame = CGRectMake(10, 10, 80, 30);
        [bohuiBtn setImage:[UIImage imageNamed:@"icon-test"] forState:UIControlStateNormal];
        [bohuiBtn setImage:[UIImage imageNamed:@"fangxuankuang2"] forState:UIControlStateSelected];
        [bohuiBtn setTitleColor:hexColor(333333) forState:UIControlStateNormal];
         [bohuiBtn setTitleColor:hexColor(333333) forState:UIControlStateSelected];
        self.bohuiBtn = bohuiBtn;
        [bohuiBtn setTitle:@"驳回" forState:UIControlStateSelected];
        [bohuiBtn setTitle:@"驳回" forState:UIControlStateNormal];
        [bohuiBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0,5)];
        [self.bohuiView addSubview:bohuiBtn];
        bohuiBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [bohuiBtn addTarget:self action:@selector(bohuiBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+80+10, 10, 120, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(666666);
        [self.bohuiView addSubview:titlelabel];
        titlelabel.text = @"发起审批" ;
    }
    
    
    self.saveBtn  = [UIButton buttonWithType:UIButtonTypeCustom];
    self.saveBtn.backgroundColor = hexColor(FFBC01);
    [self.saveBtn setTitle:@"提交" forState:UIControlStateNormal];
    self.saveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.saveBtn.frame = CGRectMake(20, maxY+20, ScreenWidth-40, 40);
    [scrollVIew addSubview:self.saveBtn];
    
    self.saveBtn.clipsToBounds = YES;
    self.saveBtn.layer.cornerRadius = 5;
    
    scrollVIew.contentSize = CGSizeMake(0, CGRectGetMaxY(self.saveBtn.frame)+10);
    [self.saveBtn addTarget:self action:@selector(subData:) forControlEvents:UIControlEventTouchUpInside];
   
}
- (void)selectCopyToDepartment{
     if (self.copToParentArray.count == 0) {
          [MBProgressHUD showWarnMessage:@"暂无可选抄送单位!"];
          return;
      }
      WS
      if (!self.copToParentArray) {
          [MBProgressHUD showTipMessageInWindow:@"解析中"];
      } else {
          LSTestViewController *testVC = [[LSTestViewController alloc] init];
        if ([ValidateUtils validateNull:self.detailDict[@"COPY_TO"]].length != 0) {
             NSArray *selectModelArray = [[ValidateUtils validateNull:self.detailDict[@"COPY_TO"]] componentsSeparatedByString:@","];
             NSArray *nameArray = [[ValidateUtils validateNull:self.detailDict[@"DEPART_NAMES"]] componentsSeparatedByString:@","];
             if (selectModelArray.count > 0) {
                 for (NSInteger i = 0; i < selectModelArray.count; i++) {
                     NSString *idStr = selectModelArray[i];
                     if (![[ValidateUtils validateNull:idStr] isEqualToString:@""]) {
                         LSTestSelectModel *model = [LSTestSelectModel testSelectModelWithDict:@{@"id":idStr,@"name":nameArray[i]}];
                         [testVC.selectedModelArray addObject:model];
                     }
                 }
                
             }
         }
          testVC.dataModelArrayM = self.copToParentArray;
          testVC.didSelectAreaModelBlock = ^(NSArray<LSTestSelectModel *> * _Nonnull modelArray) {
              if (modelArray.count > 0) {
                  NSString *nameString = @"";
                  for (LSTestSelectModel *testModel in modelArray) {
                      weakSelf.selectCopyToDepartmentString = [weakSelf.selectCopyToDepartmentString stringByAppendingFormat:@"%@,",testModel.id];
                      nameString = [nameString stringByAppendingFormat:@"%@,",testModel.name];
                  }
                  weakSelf.paraDict[@"COPY_TO"] =  weakSelf.selectCopyToDepartmentString;
                  UITextView *textView = [weakSelf.view viewWithTag: 106];
                  textView.text = [nameString substringToIndex:nameString.length-1];
                  [weakSelf textViewDidChange:textView];
              }
          };
          [self presentViewController:testVC animated:true completion:nil];
      }
}
#pragma mark - 加载抄送单位
- (void)copyToDepartment{
    WS
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",getSendList,[UserInfoModel sharedInstance].token] param:@{} completionHandler:^(id responseObject, NSError *connectionError) {
        if (!connectionError) {
            NSNumber *status = responseObject[@"status"];
            if (status.intValue == 200) {
                NSArray *array = responseObject[@"data"];
                if (array && array.count>0) {
                    [self.copToParentArray removeAllObjects];
                    //                    [self.copyToDepartmentArray removeAllObjects];
                    for (NSInteger i = 0; i < array.count; i++) {
                        NSMutableDictionary *dict = [array[i] mutableCopy];
                        LSTestSelectModel *model = [LSTestSelectModel testSelectModelWithDict:dict];
                        if (model) [weakSelf.copToParentArray addObject:model];
                    }
                }
            }
        }
    }];
}

- (void)textViewDidChange:(UITextView *)textView{
    if (textView.tag == 9000) {
        [textView flashScrollIndicators];   // 闪动滚动条
      static CGFloat maxHeight = 10000000.0f;
      CGRect frame = textView.frame;
      CGSize constraintSize = CGSizeMake(frame.size.width, MAXFLOAT);
      CGSize size = [textView sizeThatFits:constraintSize];
      if (size.height >= maxHeight)
      {
          size.height = maxHeight;
          textView.scrollEnabled = YES;    // 允许滚动
      }
      else
      {
          textView.scrollEnabled = NO;    // 不允许滚动，当textview的大小足以容纳它的text的时候，需要设置scrollEnabed为NO，否则会出现光标乱滚动的情况
      }
        if (size.height > 30) {
            CGRect bottomFrame = self.bottomVIew.frame;
                   bottomFrame.size.height = bottomFrame.size.height+(size.height-frame.size.height);
                    self.bottomVIew.frame = bottomFrame;
                   
                   UIView *yujianView = [self.view viewWithTag:10000];
                   CGRect yijianFrame = yujianView.frame;
                   yijianFrame.size.height = yijianFrame.size.height+(size.height-frame.size.height);
                   yujianView.frame = yijianFrame;
                  
                 textView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, size.height);
            UIView *lineVIew = [self.view viewWithTag:9001];
            lineVIew.frame = CGRectMake(0, CGRectGetMaxY(textView.frame)+9, ScreenWidth, 1);
                   CGFloat yijianY = CGRectGetMaxY(yujianView.frame);
            if (self.bohuiBtn.selected) {
                if ([ValidateUtils validateNull:self.progressDict[@"histListSize"]].integerValue > 0){
                       self.bohuiView.frame = CGRectMake(0, yijianY, ScreenWidth, 50);
                       yijianY = CGRectGetMaxY(self.bohuiView.frame);
                  }
            }else{
                if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"] ){
                                       self.jieDianView.frame = CGRectMake(0, yijianY+1, ScreenWidth, 100);
                                      yijianY = CGRectGetMaxY(self.jieDianView.frame);
                                  }
                                 
                                  if ([ValidateUtils validateNull:self.progressDict[@"histListSize"]].integerValue > 0){
                                       self.bohuiView.frame = CGRectMake(0, yijianY, ScreenWidth, 50);
                                       yijianY = CGRectGetMaxY(self.bohuiView.frame);
                                  }
            }
                  
            CGRect saveFrame = self.saveBtn.frame ;
                       saveFrame.origin.y = saveFrame.origin.y+size.height-frame.size.height;
                       self.saveBtn.frame = saveFrame;
            self.saveBtn.frame = saveFrame;
             self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.saveBtn.frame)+10);
        }
        
    }else{
        if (textView.tag != 108) {
               static CGFloat maxHeight = 10000000.0f;
                 CGRect frame = textView.frame;
                 CGSize constraintSize = CGSizeMake(frame.size.width, MAXFLOAT);
                 CGSize size = [textView sizeThatFits:constraintSize];
                 if (size.height >= maxHeight)
                 {
                     size.height = maxHeight;
                     textView.scrollEnabled = YES;    // 允许滚动
                 }
                 else
                 {
                     textView.scrollEnabled = NO;    // 不允许滚动，当textview的大小足以容纳它的text的时候，需要设置scrollEnabed为NO，否则会出现光标乱滚动的情况
                 }
               if (size.height > 30) {
                   UIView *view = [self.view viewWithTag:textView.tag%100+100000];
                   UIView *lineView = [self.view viewWithTag:textView.tag%100+400000];
                   CGRect viewframe = view.frame;
                   viewframe.size.height = viewframe.size.height+(size.height-frame.size.height);
                   view.frame = viewframe;
                   
                   UIImageView *redImage = [self.view viewWithTag:textView.tag%100+200000];
                   CGRect redFrame = redImage.frame;
                   redFrame.origin.y = (view.frame.size.height-redFrame.size.height)/2.0;
                   redImage.frame = redFrame;
                   
                   UILabel *titlelabel = [self.view viewWithTag:textView.tag%100+300000];
                   CGRect titleFrame = titlelabel.frame;
                   titleFrame.origin.y = (view.frame.size.height-titleFrame.size.height)/2.0;
                   titlelabel.frame = titleFrame;

                   textView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, size.height);
                   lineView.frame = CGRectMake(0, CGRectGetMaxY(textView.frame)+9, ScreenWidth, 1);
                   [self changeViewPositionWithFromTag:textView.tag];
               }
           }
    }
   
}
#pragma mark - 根据文字刷新界面
- (void)changeViewPositionWithFromTag:(NSInteger)tag{
    CGFloat maxY = 0;
    if (self.type == 1) {
        for (NSInteger i = tag+1; i<111; i++) {
          UIView *topview = [self.view viewWithTag:(i-1)%100+100000];
           UIView *bottomView = [self.view viewWithTag:i%100+100000];
           CGRect viewframe = bottomView.frame;
           viewframe.origin.y = CGRectGetMaxY(topview.frame);
           bottomView.frame = viewframe;
               maxY = CGRectGetMaxY(bottomView.frame);
           }
    }else{
        for (NSInteger i = tag+1; i<109; i++) {
          UIView *topview = [self.view viewWithTag:(i-1)%100+100000];
           UIView *bottomView = [self.view viewWithTag:i%100+100000];
           CGRect viewframe = bottomView.frame;
           viewframe.origin.y = CGRectGetMaxY(topview.frame);
           bottomView.frame = viewframe;
               maxY = CGRectGetMaxY(bottomView.frame);
           }
    }
   
    CGRect fujianFrame = self.fujianView.frame;
    fujianFrame.origin.y = maxY;
    self.fujianView.frame = fujianFrame;
    CGRect progressFrame = self.progressHistoryView.frame;
    progressFrame.origin.y = CGRectGetMaxY(self.fujianView.frame)+10;
    self.progressHistoryView.frame = progressFrame;
    NSArray *histListNode = [NSArray arrayWithArray:self.progressDict[@"bpmLogList"]];
     if (histListNode.count != 0) {
           maxY = CGRectGetMaxY(self.progressHistoryView.frame);
       }else{
           maxY = CGRectGetMaxY(self.progressHistoryView.frame)-10;
       }
    CGRect bottomViewFrame = self.bottomVIew.frame;
    bottomViewFrame.origin.y = maxY+10;
    self.bottomVIew.frame  = bottomViewFrame;
    self.saveBtn.frame = CGRectMake(20, CGRectGetMaxY(self.bottomVIew.frame)+20, (ScreenWidth-60), 40);
    self.scrollView.contentSize  =CGSizeMake(0, CGRectGetMaxY(self.saveBtn.frame)+20);
}
- (void)bohuiBtnClicked:(UIButton*)button{
    if (button.selected) {
        self.paraDict[@"rejectModelNode"] =@"";
        self.paraDict[@"taskName"] = @"";
        if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"] ) {
            self.jieDianView.hidden = NO;
            self.bohuiView.frame = CGRectMake(0, CGRectGetMaxY(self.jieDianView.frame), ScreenWidth, 50);
            CGRect frame = self.bottomVIew.frame;
            frame.size.height = frame.size.height+100;
            self.bottomVIew.frame = frame;
            CGRect saveFrame = self.saveBtn.frame ;
            saveFrame.origin.y = saveFrame.origin.y+100;
            self.saveBtn.frame = saveFrame;
            self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.saveBtn.frame)+10);
        }
    }else{
       
        NSArray *arr = [NSArray arrayWithArray:self.progressDict[@"histListNode"]];
        if (arr.count != 0) {
            self.paraDict[@"rejectModelNode"] = arr[0][@"task_def_key_"];
            self.paraDict[@"taskName"] = arr[0][@"name_"];
        }else{
            self.paraDict[@"rejectModelNode"] =@"";
            self.paraDict[@"taskName"] = @"";
        }
        if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"] ) {
            self.jieDianView.hidden = YES;
            self.bohuiView.frame = CGRectMake(0, 80, ScreenWidth, 50);
            CGRect frame = self.bottomVIew.frame;
            frame.size.height = frame.size.height-100;
            self.bottomVIew.frame = frame;
            CGRect saveFrame = self.saveBtn.frame ;
            saveFrame.origin.y = saveFrame.origin.y-100;
            self.saveBtn.frame = saveFrame;
            self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.saveBtn.frame)+10);
        }
    
    }
    button.selected = !button.selected;
}
#pragma mark 选择节点处理人
- (void)chooseJieDianChuLuRen{
    UITextField *textField = [self.view viewWithTag:8001];
    
    //initWithCompleteHandler
    LSContactSelectViewController *lvc = [[LSContactSelectViewController alloc]initWithCompleteHandler:^(LSContactSelectTableViewModel * _Nonnull model) {
        self.paraDict[@"id"] = model.username;
        textField.text = model.realname;
        
    }];
    HEBaseNavController *nav = [[HEBaseNavController alloc] initWithRootViewController:lvc];
    [self presentViewController:nav animated:true completion:nil];
}

- (void)xuanzexiayigejiemian{
    
}

- (void)addFiles{
    LSDownloadFilesViewController *lvc = [[LSDownloadFilesViewController alloc] initWithEditableTableViewWithSelectedFilesArray:self.filesArray andDidSelectFilesBlock:^(NSArray * _Nonnull selectedFilesArray) {
        if (selectedFilesArray.count > 0) {
            [self.filesArray removeAllObjects];
            [self.filesArray addObjectsFromArray: selectedFilesArray];
            NSLog(@"selectedFilesArray---%@",selectedFilesArray);
            [self changeFuJIanUI];
        }
    }];
    [self.navigationController pushViewController:lvc animated:YES];
}
#pragma mark 提交
- (void)subData:(UIButton*)button{
    [self.view endEditing:YES];
    UITextView *textfield = [self.view viewWithTag:9000];
    if (textfield.text.length == 0) {
        [MBProgressHUD showWarnMessage:@"请输入办理意见！"];
        return;
    }
    NSArray *arr1 = [NSArray arrayWithArray:self.progressDict[@"transitionList"]];
    if (arr1.count > 0) {
        self.paraDict[@"nextnode"] = arr1.firstObject[@"nextnode"];
    }else{
        self.paraDict[@"nextnode"] = @"";
    }
    if (![self.dict[@"taskName"] isEqualToString:@"发起审批"]) {

        self.paraDict[@"nextCodeCount"] = self.progressDict[@"nextCodeCount"];
        if ([[ValidateUtils validateNull:self.progressDict[@"taskName"]] isEqualToString:@"科室转发"]) {
            if (!self.bohuiBtn.selected) {
                self.paraDict[@"model"] = @"1";
                if ([[ValidateUtils validateNull:self.paraDict[@"id"]] isEqualToString:@""]) {
                    [MBProgressHUD showWarnMessage:@"请选择处理人"];
                    return;
                }
            }else{
                self.paraDict[@"model"] = @"3";
            }
        }else{
            if (!self.bohuiBtn.selected) {
                self.paraDict[@"model"] = @"1";
            }else{
                self.paraDict[@"model"] = @"3";
            }
        }
       
    }else{
        self.paraDict[@"model"] = @"1";
        self.paraDict[@"SELECT_TASKNODE"] = @"";
        self.paraDict[@"taskName"] = @"";
        self.paraDict[@"id"] = @"";
        self.paraDict[@"nextCodeCount"] = [ValidateUtils validateNull:self.progressDict[@"nextCodeCount"]];
    }
    NSLog(@"参数%@",self.paraDict);
    
    if (self.filesArray.count>0) {
        NSMutableArray *nameArr = [NSMutableArray array];
        NSMutableArray *fileNameArr = [NSMutableArray array];
        NSMutableArray *dataArray = [NSMutableArray array];
        for (NSInteger i = 0; i < self.filesArray.count; i++) {
            NSString *filePath = self.filesArray[i];
            NSData *data = [self readFileData:filePath];
            [nameArr addObject:[NSString stringWithFormat:@"File%ld",i+1]];
            [fileNameArr addObject:[filePath componentsSeparatedByString:@"/"].lastObject];
            [dataArray addObject:data];
        }
         MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [NetworkUtils uploadFileNoHandleWithURL:[NSString stringWithFormat:@"%@&token=%@",yzFileDeal,[UserInfoModel sharedInstance].token] param:@{}.mutableCopy data:dataArray name:nameArr filename:fileNameArr completionHandler:^(id responseObject, NSError *connectionError) {
            [hud hideAnimated:true];
            if (!connectionError) {
                NSNumber *status = [responseObject objectForKey:@"status"];
                
                if (status.integerValue == 200) {
                    NSMutableString *filePath = [NSMutableString string];
                    
                    if (self.upLoadFileArray.count>0) {
                        for (NSInteger i = 0; i< self.upLoadFileArray.count; i++) {
                            NSDictionary *fileDict = self.upLoadFileArray[i];
                            [filePath appendFormat:@"%@,",fileDict[@"filePath"]];
                        }
                    }
                    NSArray *arr = [NSArray arrayWithArray:responseObject[@"attachment"]];
                    for (NSInteger i = 0; i< arr.count; i++) {
                        NSDictionary *fileDict = arr[i];
                        if (i != arr.count-1) {
                            [filePath appendFormat:@"%@,",fileDict[@"filePath"]];
                        }else{
                            [filePath appendFormat:@"%@",fileDict[@"filePath"]];
                        }
                        
                    }
                    
                    self.detailDict[@"attachment"] = filePath;
                    [self uploadData];
                    
                } else {
                    if ([responseObject[@"message"] isEqualToString:@"数据异常，请联系管理员"]) {
                        NSLog(@"就是这个接口--yzFileDeal");
                    }
                    [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                    [self uploadData];
                }
            } else {
                [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
                [self uploadData];
            }
            
        }];
        
    }else{
        NSMutableString *filePath = [NSMutableString string];
        
        if (self.upLoadFileArray.count>0) {
            for (NSInteger i = 0; i< self.upLoadFileArray.count; i++) {
                NSDictionary *fileDict = self.upLoadFileArray[i];
                if (i != self.upLoadFileArray.count-1) {
                    [filePath appendFormat:@"%@,",fileDict[@"filePath"]];
                }else{
                    [filePath appendFormat:@"%@",fileDict[@"filePath"]];
                }
            }
        }
        self.detailDict[@"attachment"] = filePath;
        [self uploadData];
    }
    
    
}
-(NSData*)readFileData:(NSString *)path{
    NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
    NSData *fileData = [handle readDataToEndOfFile];
    [handle closeFile];
    return fileData;
}
- (void)uploadData{
    if (self.type == 1) {
        if ([ValidateUtils validateNull:self.detailDict[@"FILE_TITLE"]].length <= 1) {
               [MBProgressHUD showWarnMessage:@"请填写2到100位任意字符"];
               return;
           }
           if ([ValidateUtils validateNull:self.detailDict[@"FILE_REASON"]].length <= 1) {
               [MBProgressHUD showWarnMessage:@"请填写2到100位任意字符"];
               return;
           }
           if ([ValidateUtils validateNull:self.detailDict[@"FILE_CODE"]].length < 2) {
               [MBProgressHUD showWarnMessage:@"请填写2到16位任意字符"];
               return;
           }
           if ([ValidateUtils validateNull:self.detailDict[@"HOST_ORGAN"]].length < 2) {
               [MBProgressHUD showWarnMessage:@"请填写2到30位任意字符"];
               return;
           }
           if ([ValidateUtils validateNull:self.detailDict[@"PRINT_COUNT"]].length == 0) {
               [MBProgressHUD showWarnMessage:@"请填写1到3位任意数字"];
               return;
           }
        NSDictionary*dict= @{@"attachment":[ValidateUtils validateNull:self.detailDict[@"attachment"]],@"id":[ValidateUtils validateNull:self.detailDict[@"ID"]],@"fileReason":[ValidateUtils validateNull:self.detailDict[@"FILE_REASON"]],@"fileTitle":[ValidateUtils validateNull:self.detailDict[@"FILE_TITLE"]],@"fileCode":[ValidateUtils validateNull:self.detailDict[@"FILE_CODE"]],@"rank":[ValidateUtils validateNull:self.detailDict[@"RANK"]],@"isOpen":[ValidateUtils validateNull:self.detailDict[@"IS_OPEN"]],@"hostOrgan":[ValidateUtils validateNull:self.detailDict[@"HOST_ORGAN"]],@"copyTo":[ValidateUtils validateNull:self.detailDict[@"COPY_TO"]],@"printCount":[ValidateUtils validateNull:self.detailDict[@"PRINT_COUNT"]]};
        
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",doHandleUpdate,[UserInfoModel sharedInstance].token] param:dict completionHandler:^(id responseObject, NSError *connectionError) {
            [hud hideAnimated:true];
            if (!connectionError) {
                NSNumber *status = [responseObject objectForKey:@"status"];
                
                if (status.integerValue == 200) {
                    
                    [self subMidAllData];
                } else {
                    if ([responseObject[@"message"] isEqualToString:@"数据异常，请联系管理员"]) {
                        NSLog(@"就是这个接口--doHandleUpdate");
                    }
                    [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                }
            } else {
                [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
            }
        }];
    }else{
        if ([ValidateUtils validateNull:self.detailDict[@"FILE_TITLE"]].length <2) {
            [MBProgressHUD showTipMessageInWindow:@"请填写2到30位任意字符"];
            return;
        }
        if ([ValidateUtils validateNull:self.detailDict[@"FILE_COMPANY"]].length <2) {
                   [MBProgressHUD showTipMessageInWindow:@"请填写2到30位任意字符"];
                   return;
            }
            if ([ValidateUtils validateNull:self.detailDict[@"FILE_CODE"]].length <2) {
                              [MBProgressHUD showTipMessageInWindow:@"请填写2到16位任意字符"];
                              return;
                    }
        if ([ValidateUtils validateNull:self.detailDict[@"FILE_COUNT"]].length ==0) {
                 [MBProgressHUD showTipMessageInWindow:@"请填写1到3位任意数字"];
                 return;
            }

        NSDictionary*dict= @{@"attachment":[ValidateUtils validateNull:self.detailDict[@"attachment"]],@"id":[ValidateUtils validateNull:self.detailDict[@"ID"]],@"fileNum":[ValidateUtils validateNull:self.detailDict[@"FILE_NUM"]],@"fileReceiveDate":[ValidateUtils validateNull:self.detailDict[@"FILE_RECEIVE_DATE"]],@"fileTitle":[ValidateUtils validateNull:self.detailDict[@"FILE_TITLE"]],@"fileCompany":[ValidateUtils validateNull:self.detailDict[@"FILE_COMPANY"]],@"fileCode":[ValidateUtils validateNull:self.detailDict[@"FILE_CODE"]],@"fileClassify":[ValidateUtils validateNull:self.detailDict[@"FILE_CLASSIFY"]],@"fileCount":[ValidateUtils validateNull:self.detailDict[@"FILE_COUNT"]],@"securityClassification":[ValidateUtils validateNull:self.detailDict[@"SECURITY_CLASSIFICATION"]],@"fileRemark":[ValidateUtils validateNull:self.detailDict[@"FILE_REMARK"]]};
        
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",doybHandleUpdate,[UserInfoModel sharedInstance].token] param:dict completionHandler:^(id responseObject, NSError *connectionError) {
            [hud hideAnimated:true];
            if (!connectionError) {
                NSNumber *status = [responseObject objectForKey:@"status"];
                
                if (status.integerValue == 200) {
                    
                    [self subMidAllData];
                } else {
                    if ([responseObject[@"message"] isEqualToString:@"数据异常，请联系管理员"]) {
                        NSLog(@"就是这个接口--doybHandleUpdate");
                    }
                    [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                }
            } else {
                [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
            }
        }];
    }
   
}

- (void)subMidAllData{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",dobl,[UserInfoModel sharedInstance].token] param:self.paraDict completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
               [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                [self.navigationController popViewControllerAnimated:YES];
            } else {
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        } else {
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}
- (void)changeFuJIanUI{
    CGRect frame = self.fujianView.frame;
   frame.size.height = 50*(self.filesArray.count+1+self.upLoadFileArray.count);
        self.fujianView.frame = frame;
        NSArray *arr = self.fujianView.subviews;
        for (UIView *view in arr) {
            [view removeFromSuperview];
        }
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [self.fujianView addSubview:titlelabel];
        titlelabel.text =@"附件：";
        UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        downBtn.frame = CGRectMake(ScreenWidth-50,5 , 40, 40);
        [downBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
        [downBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        [self.fujianView addSubview:downBtn];
        downBtn.tag = 2000;
        [downBtn addTarget:self action:@selector(addFiles) forControlEvents:UIControlEventTouchUpInside];
        CGFloat maxY = CGRectGetMaxY(titlelabel.frame);
        if (self.upLoadFileArray.count > 0) {
            for (NSInteger i = 0; i < self.upLoadFileArray.count; i++) {
                NSString *filename = self.upLoadFileArray[i][@"fileName"];
                UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, maxY+10 + i*50, ScreenWidth-10-10-40, 30)];
                label.font = [UIFont systemFontOfSize:14];
                label.textColor = hexColor(333333);
                
                label.text = filename;
                [self.fujianView addSubview:label];
                UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                downBtn.frame = CGRectMake(ScreenWidth-50-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
                [downBtn setImage:[UIImage imageNamed:@"xiazai"] forState:UIControlStateNormal];
                [self.fujianView addSubview:downBtn];
                downBtn.tag = 5000+i;
                [downBtn addTarget:self action:@selector(downFileStart:) forControlEvents:UIControlEventTouchUpInside];
                
                UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                deleteBtn.frame = CGRectMake(ScreenWidth-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
                [deleteBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
                [self.fujianView addSubview:deleteBtn];
                deleteBtn.tag = 4000+i;
                [deleteBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
                UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
                lineViwe.backgroundColor = hexColor(f0f0f0);
                [self.fujianView addSubview:lineViwe];
                maxY = CGRectGetMaxY(lineViwe.frame);
            }
        }
        
        if (self.filesArray.count > 0) {
            for (NSInteger i = 0; i < self.filesArray.count; i++) {
                NSString *filename = self.filesArray[i];
                UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, maxY+10 + i*50, ScreenWidth-10-10-40, 30)];
                label.font = [UIFont systemFontOfSize:14];
                label.textColor = hexColor(333333);
                NSArray *fileNames = [filename componentsSeparatedByString:@"/"];
                label.text = fileNames.lastObject;
                [self.fujianView addSubview:label];
                UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                downBtn.frame = CGRectMake(ScreenWidth-50,maxY+5 + i*50 , 40, 40);
                [downBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
                [self.fujianView addSubview:downBtn];
                downBtn.tag = 6000+i;
                [downBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
                UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
                lineViwe.backgroundColor = hexColor(f0f0f0);
                [self.fujianView addSubview:lineViwe];
            }
        }
    
    CGRect progressFrame = self.progressHistoryView.frame;
    progressFrame.origin.y = CGRectGetMaxY(self.fujianView.frame)+10;
    self.progressHistoryView.frame = progressFrame;
    
    CGRect bottomFrame = self.bottomVIew.frame;
    if (progressFrame.size.height == 0) {
        bottomFrame.origin.y = CGRectGetMaxY(self.fujianView.frame)+10;
    }else{
        bottomFrame.origin.y = CGRectGetMaxY(self.progressHistoryView.frame)+10;
    }
    self.bottomVIew.frame = bottomFrame;
    
    
        CGRect saveFrame = self.saveBtn.frame;
        saveFrame.origin.y = CGRectGetMaxY(self.bottomVIew.frame)+20;
        self.saveBtn.frame = saveFrame;
      
        self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.saveBtn.frame)+10);
   
    
}
- (void)downFileStart:(UIButton*)button{
    //(NSString*)fileStr withFileName:(NSString*)fileName
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
     [dict addEntriesFromDictionary:self.upLoadFileArray[button.tag-5000]];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths lastObject];
    NSString *docPath = [ValidateUtils validateNull:dict[@"fileName"]];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    [NetworkUtils downloadFileWithURL:dict[@"filePath2"] filePath:[NSString stringWithFormat:@"%@/%@",documentsDirectory,docPath] progress:^(NSProgress *downloadProgress) {
        
    } completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        if (!connectionError) {
            
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"系统提示" message:@"下载完成，是否查看？" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *queding = [UIAlertAction actionWithTitle:@"查看" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                LSDownloadFilesViewController *lvc = [[LSDownloadFilesViewController alloc]init];
                [self.navigationController pushViewController:lvc animated:YES];
            }];
            UIAlertAction *quxiao = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                
            }];
            [alert addAction:quxiao];
            [alert addAction:queding];
            [self presentViewController:alert animated:YES completion:nil];
            
        } else {
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}
//新增删除文件
- (void)delectFile:(UIButton*)button{
        if (button.tag >= 6000) {
            [self.filesArray removeObjectAtIndex:button.tag-6000];
            [self changeFuJIanUI];
        }else{
            
            MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            NSDictionary *para = @{@"filePath":self.upLoadFileArray[button.tag-4000][@"filePath2"]};
            [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",yzFileDeletel,[UserInfoModel sharedInstance].token] param:para completionHandler:^(id responseObject, NSError *connectionError) {
                [hud hideAnimated:true];
                if (!connectionError) {
                    NSNumber *status = [responseObject objectForKey:@"status"];
                    
                    if (status.integerValue == 200) {
                        [self.upLoadFileArray removeObjectAtIndex:button.tag - 4000];
                        [self changeFuJIanUI];
                    } else {
                        if ([responseObject[@"message"] isEqualToString:@"数据异常，请联系管理员"]) {
                            NSLog(@"就是这个接口--yzFileDeletel");
                        }
                        [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                    }
                } else {
                    
                    [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
                }
            }];
        }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
